{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 7.13 Flow given in English Units - Oil"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Fuel oil at a specific gravity of 0.815 (kinematic viscosity of 2.7 centistokes) flows at 2 inch, schedule 40 steel pipe 100 foot long at a rate of 2 US gallons/second.\n",
    "\n",
    "Calculate the pressure drop in bars and psi."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Darcy friction factor = 0.02270215687134065 dimensionless\n",
      "Pressure drop = 65759.12280469094 pascal\n",
      "In imperial, pressure drop = 9.537554406715385 pound_force_per_square_inch\n"
     ]
    }
   ],
   "source": [
    "from math import *\n",
    "from fluids.units import *\n",
    "from thermo import *\n",
    "\n",
    "SG = 0.815\n",
    "rho = SG*999.1*u.kg/u.m**3\n",
    "nu = 2.7*u.centistokes\n",
    "mu = nu_mu_converter(rho,  nu=nu)\n",
    "Q = 2*u.gal/u.s\n",
    "L = 100*u.foot\n",
    "\n",
    "NPS, D_pipe, Do_pipe, t = nearest_pipe(Di=2*u.inch)\n",
    "v = Q/(pi/4*D_pipe**2)\n",
    "Re = Reynolds(rho=rho, mu=mu, D=D_pipe, V=v)\n",
    "fd = friction_factor(Re=Re, eD=0.0018*u.inch/D_pipe)\n",
    "print('Darcy friction factor = %s' %fd)\n",
    "K_friction = K_from_f(fd=fd, L=L, D=D_pipe)\n",
    "dP = dP_from_K(K=K_friction, rho=rho, V=v)\n",
    "print('Pressure drop = %s' %dP.to(u.Pa))\n",
    "print('In imperial, pressure drop = %s' %dP.to(u.psi))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The pressure drop calculated in the example is 66500 Pa (9.65 psi). The discrepancy is from their friction factor; they use 0.0230. The result is matched exactly if their friction factor is used."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Darcy friction factor = 0.023\n",
      "Pressure drop = 66621.85593551381 pascal\n",
      "In imperial, pressure drop = 9.662683268274836 pound_force_per_square_inch\n"
     ]
    }
   ],
   "source": [
    "fd = 0.023\n",
    "print('Darcy friction factor = %s' %fd)\n",
    "K_friction = K_from_f(fd=fd, L=L, D=D_pipe)\n",
    "dP = dP_from_K(K=K_friction, rho=rho, V=v)\n",
    "print('Pressure drop = %s' %dP.to(u.Pa))\n",
    "print('In imperial, pressure drop = %s' %dP.to(u.psi))"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
